package net.projecteuler.prob;

import net.projecteuler.util.FactorUtil;

public class Problem75 implements Runnable {

	private static final int MAX = 1500000;
	private static final int MAX_M = 866;
	
	@Override
	public void run() {
		int[] triAngleCnts = new int[MAX + 1];
		
		for(int m = 1; m <= MAX_M; m++){
			for(int n = 1; n < m; n++){
				if(((m - n) % 2 == 1) && FactorUtil.isCoprimeEuclidean(m, n)){
					int LFund = 2 * m * (m + n);
					int k = 1;
					while(true){
						if(LFund * k <= MAX)
							triAngleCnts[LFund * (k++)]++;
						else
							break;
					}
				}
			}
		}
		
		int maxCnt = 0;
		int oneCnt = 0;
		int maxL = 0;
		for(int i = 0; i < MAX + 1; i++){
			if(triAngleCnts[i] == 1){
				oneCnt++;
			}
				
			if(triAngleCnts[i] > maxCnt){
				maxL = i;
				maxCnt = triAngleCnts[i];
			}
		}
		
		System.out.println("oneCnt : " + oneCnt);
		System.out.println("maxCnt : " + maxCnt + "(L=" + maxL + ")");
		
	}

}
